home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-12-12 | 1.9 KB | 59 lines | [TEXT/CWIE] |
- import java.awt.*;
-
- // not finished. For now, just use the static methods
- public class GBConstrainer
- {
- protected Container mCont = null;
-
- protected GBConstrainer(Container c)
- { mCont = c; }
-
- public static void constrain(Container cont, Component component, int grid_y, int grid_x)
- {
- constrain(cont, component, grid_y, grid_x, 1, 1,
- 1, 1, 1, 1, true, GridBagConstraints.NORTHWEST);
- }
-
- public static void constrain(Container cont, Component component, int grid_y, int grid_x,
- int cell_width, int cell_height, boolean grow)
- {
- constrain(cont, component, grid_y, grid_x, cell_width, cell_height,
- 1, 1, 1, 1, grow, GridBagConstraints.NORTHWEST);
- }
-
- public static void constrain(Container cont, Component component, int grid_y, int grid_x,
- int cell_width, int cell_height, boolean grow, int wa)
- {
- constrain(cont, component, grid_y, grid_x, cell_width, cell_height,
- 1, 1, 1, 1, grow, wa);
- }
-
- public static void constrain(Container cont, Component component, int grid_y, int grid_x,
- int cell_width, int cell_height,
- int top, int left, int bottom, int right, boolean grow)
- {
- constrain(cont, component, grid_y, grid_x, cell_width, cell_height,
- top, left, bottom, right, grow, GridBagConstraints.NORTHWEST);
- }
-
- public static void constrain(Container cont, Component component, int grid_y, int grid_x,
- int cell_width, int cell_height,
- int top, int left, int bottom, int right, boolean grow, int pos)
- {
- GridBagConstraints c =new GridBagConstraints();
- c.gridx = grid_x;
- c.gridy = grid_y;
- c.gridwidth = cell_width;
- c.gridheight = cell_height;
- if (grow)
- c.fill = GridBagConstraints.BOTH;
- else
- c.fill = GridBagConstraints.NONE;
- c.anchor = pos;
- c.weightx = c.weighty = 0.0;
- if (top + left + bottom + right > 0)
- c.insets = new Insets(top, left, bottom, right);
- ((GridBagLayout)cont.getLayout()).setConstraints(component, c);
- cont.add(component);
- }
- }